package jun.learn.spring.transaction;

import java.sql.Connection;
import java.sql.DatabaseMetaData;
import java.sql.SQLException;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.jdbc.datasource.DriverManagerDataSource;

public class TxTest {
	public static void main(String[] args) {
		ApplicationContext ctx = new ClassPathXmlApplicationContext("applicationContext.xml");
		DriverManagerDataSource dataSource = (DriverManagerDataSource)ctx.getBean("myDataSource");
		System.out.println(dataSource);
		try {
			Connection conn = dataSource.getConnection();
			System.out.println(conn);
			DatabaseMetaData metaData = conn.getMetaData();
			int majorVersion =  metaData.getDatabaseMajorVersion();
			System.out.println(majorVersion);
			String productName = metaData.getDatabaseProductName();
			System.out.println(productName);
		} catch (SQLException e) {
			e.printStackTrace();
		}
	}
}

